package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysOrderEvaluate;
import com.ruoyi.project.system.service.ISysOrderEvaluateService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 订单评价Controller
 * 
 * @author jjp
 * @date 2020-04-29
 */
@RestController
@Api("订单评价")
@RequestMapping("/system/evaluate")
public class SysOrderEvaluateController extends BaseController
{
    @Autowired
    private ISysOrderEvaluateService sysOrderEvaluateService;

    /**
     * 查询订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:list')")
    @ApiOperation("查询订单评价列表")
    @GetMapping("/list")
    public TableDataInfo list(SysOrderEvaluate sysOrderEvaluate)
    {
        startPage();
        List<SysOrderEvaluate> list = sysOrderEvaluateService.selectSysOrderEvaluateList(sysOrderEvaluate);
        return getDataTable(list);
    }

    /**
     * 获取订单评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:query')")
    @ApiOperation("获取订单评价详细信息")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") Long evaluateId)
    {
        return AjaxResult.success(sysOrderEvaluateService.selectSysOrderEvaluateById(evaluateId));
    }

    /**
     * 新增订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:add')")
    @ApiOperation("新增订单评价")
    @Log(title = "订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysOrderEvaluate sysOrderEvaluate)
    {
        return toAjax(sysOrderEvaluateService.insertSysOrderEvaluate(sysOrderEvaluate));
    }

    /**
     * 修改订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:edit')")
    @ApiOperation("修改订单评价")
    @Log(title = "订单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysOrderEvaluate sysOrderEvaluate)
    {
        return toAjax(sysOrderEvaluateService.updateSysOrderEvaluate(sysOrderEvaluate));
    }

    /**
     * 删除订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:remove')")
    @ApiOperation("删除订单评价")
    @Log(title = "订单评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateIds)
    {
        return toAjax(sysOrderEvaluateService.deleteSysOrderEvaluateByIds(evaluateIds));
    }
}
